#ifndef __BASICGUI_H
#define __BASICGUI_H

#ifdef __cplusplus
 extern "C" {
#endif

#include "DisplayDriver.h"

#if ENABLE_LCD
	 

#define GUI_COLOR_BLUE          0xFF0000FFUL
#define GUI_COLOR_GREEN         0xFF00FF00UL
#define GUI_COLOR_RED           0xFFFF0000UL
#define GUI_COLOR_CYAN          0xFF00FFFFUL
#define GUI_COLOR_MAGENTA       0xFFFF00FFUL
#define GUI_COLOR_YELLOW        0xFFFFFF00UL
#define GUI_COLOR_LIGHTBLUE     0xFF8080FFUL
#define GUI_COLOR_LIGHTGREEN    0xFF80FF80UL
#define GUI_COLOR_LIGHTRED      0xFFFF8080UL
#define GUI_COLOR_LIGHTCYAN     0xFF80FFFFUL
#define GUI_COLOR_LIGHTMAGENTA  0xFFFF80FFUL
#define GUI_COLOR_LIGHTYELLOW   0xFFFFFF80UL
#define GUI_COLOR_DARKBLUE      0xFF000080UL
#define GUI_COLOR_DARKGREEN     0xFF008000UL
#define GUI_COLOR_DARKRED       0xFF800000UL
#define GUI_COLOR_DARKCYAN      0xFF008080UL
#define GUI_COLOR_DARKMAGENTA   0xFF800080UL
#define GUI_COLOR_DARKYELLOW    0xFF808000UL
#define GUI_COLOR_WHITE         0xFFFFFFFFUL
#define GUI_COLOR_LIGHTGRAY     0xFFD3D3D3UL
#define GUI_COLOR_GRAY          0xFF808080UL
#define GUI_COLOR_DARKGRAY      0xFF404040UL
#define GUI_COLOR_BLACK         0xFF000000UL
#define GUI_COLOR_BROWN         0xFFA52A2AUL
#define GUI_COLOR_ORANGE        0xFFFFA500UL

/* Defintion of Official ST Colors */
#define GUI_COLOR_ST_BLUE_DARK   0xFF002052UL
#define GUI_COLOR_ST_BLUE        0xFF39A9DCUL
#define GUI_COLOR_ST_BLUE_LIGHT  0xFFD1E4F3UL
#define GUI_COLOR_ST_GREEN_LIGHT 0xFFBBCC01UL
#define GUI_COLOR_ST_GREEN_DARK  0xFF003D14UL
#define GUI_COLOR_ST_YELLOW      0xFFFFD300UL
#define GUI_COLOR_ST_BROWN       0xFF5C0915UL
#define GUI_COLOR_ST_PINK        0xFFD4007AUL
#define GUI_COLOR_ST_PURPLE      0xFF590D58UL
#define GUI_COLOR_ST_GRAY_DARK   0xFF4F5251UL
#define GUI_COLOR_ST_GRAY        0xFF90989EUL
#define GUI_COLOR_ST_GRAY_LIGHT  0xFFB9C4CAUL

#define ABS(X)                 ((X) > 0 ? (X) : -(X))
#define POLY_X(Z)              ((int32_t)((Points + (Z))->X))
#define POLY_Y(Z)              ((int32_t)((Points + (Z))->Y))

#define CONVERT_ARGB88882RGB565(Color)((((Color & 0xFFU) >> 3) & 0x1FU) |\
                                     (((((Color & 0xFF00U) >> 8) >>2) & 0x3FU) << 5) |\
                                     (((((Color & 0xFF0000U) >> 16) >>3) & 0x1FU) << 11))

#define CONVERT_RGB5652ARGB8888(Color)(((((((Color >> 11) & 0x1FU) * 527) + 23) >> 6) << 16) |\
                                     ((((((Color >> 5) & 0x3FU) * 259) + 33) >> 6) << 8) |\
                                     ((((Color & 0x1FU) * 527) + 23) >> 6) | 0xFF000000)
	
typedef struct
{
  int16_t X; /*!< geometric X position of drawing */
  int16_t Y; /*!< geometric Y position of drawing */
} Point,* pPoint;

typedef struct
{
  uint32_t x1;
  uint32_t y1;
  uint32_t x2;
  uint32_t y2;
  uint32_t x3;
  uint32_t y3;
}Triangle_Positions_t;

void		GUI_Clean(void);
uint32_t 	GUI_ReadPoint(uint16_t x, uint16_t y);
void 		GUI_DrawPoint(UINT16 _x, UINT16 _y,UINT32 _color,UINT8 _scale);
void 		GUI_ShowChar(UINT16 _x,UINT16 _y,UINT8 _char);
void 		GUI_ShowString(UINT16 _x,UINT16 _y,UINT16 _width,UINT16 _height,UINT8 *_ptr);
void		GUI_DrawLine(UINT16 x1, UINT16 y1, UINT16 x2, UINT16 y2,UINT32 color);
void		GUI_DrawHLine(UINT16 x0,UINT16 y0,UINT16 len,UINT32 color);
void		GUI_DrawVLine(UINT16 x0,UINT16 y0,UINT16 len,UINT32 color);
void 		GUI_DrawRect(UINT16 Xpos, UINT16 Ypos, UINT16 Width, UINT16 Height, UINT32 Color);
void 		GUI_FillRect(UINT16 Xpos, UINT16 Ypos, UINT16 Width, UINT16 Height, UINT32 Color);
void 		GUI_DrawCircle(UINT16 Xpos, UINT16 Ypos, UINT16 Radius, UINT32 Color);
void 		GUI_FillCircle(UINT16 Xpos, UINT16 Ypos, UINT16 Radius, UINT32 Color);
void 		GUI_DrawEllipse(int Xpos, int Ypos, int XRadius, int YRadius, uint32_t Color);
void 		GUI_FillEllipse(int Xpos, int Ypos, int XRadius, int YRadius, uint32_t Color);	
void 		GUI_DrawPolygon(pPoint Points, uint32_t PointCount, uint32_t Color);
void 		GUI_FillPolygon(pPoint Points, uint32_t PointCount, uint32_t Color);
void 		GUI_FillTriangle(Triangle_Positions_t *Positions, uint32_t Color);

void 		GUI_GrayHor16(void);
void 		GUI_GrayHor32(void);
void 		GUI_ScaleHor_Red(void);
void 		GUI_ScaleHor_Green(void);
void 		GUI_ScaleHor_Blue(void);
void 		GUI_ScaleHor1(void);
void 		GUI_ScaleHor2(void);

#endif
#ifdef __cplusplus
}
#endif
#endif


